package com.netease.image.video;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.MotionEvent;
import java.util.ArrayList;
import java.util.Iterator;

class CropImageView extends ImageViewTouchBase
{
  ArrayList a = new ArrayList();
  ao b = null;
  float c;
  float d;
  int e;

  public CropImageView(Context paramContext, AttributeSet paramAttributeSet)
  {
    super(paramContext, paramAttributeSet);
  }

  private void a(MotionEvent paramMotionEvent)
  {
    int i = 0;
    for (int j = 0; j < this.a.size(); j++)
    {
      ao localao2 = (ao)this.a.get(j);
      localao2.a(false);
      localao2.c();
    }
    while (true)
    {
      i++;
      if (i >= this.a.size())
        break;
      ao localao1 = (ao)this.a.get(i);
      if (localao1.a(paramMotionEvent.getX(), paramMotionEvent.getY()) == 1)
        continue;
      if (localao1.a())
        break;
      localao1.a(true);
      localao1.c();
    }
    invalidate();
  }

  private void b(ao paramao)
  {
    Rect localRect = paramao.j;
    int i = Math.max(0, getLeft() - localRect.left);
    int j = Math.min(0, getRight() - localRect.right);
    int k = Math.max(0, getTop() - localRect.top);
    int m = Math.min(0, getBottom() - localRect.bottom);
    if (i != 0)
      if (k == 0)
        break label98;
    while (true)
    {
      if ((i != 0) || (k != 0))
        b(i, k);
      return;
      i = j;
      break;
      label98: k = m;
    }
  }

  private void c(ao paramao)
  {
    Rect localRect = paramao.j;
    float f1 = localRect.width();
    float f2 = localRect.height();
    float f3 = getWidth();
    float f4 = getHeight();
    float f5 = Math.max(1.0F, Math.min(0.6F * (f3 / f1), 0.6F * (f4 / f2)) * d());
    if (Math.abs(f5 - d()) / f5 > 0.1D)
    {
      float[] arrayOfFloat = new float[2];
      arrayOfFloat[0] = paramao.k.centerX();
      arrayOfFloat[1] = paramao.k.centerY();
      getImageMatrix().mapPoints(arrayOfFloat);
      a(f5, arrayOfFloat[0], arrayOfFloat[1], 300.0F);
    }
    b(paramao);
  }

  protected void a(float paramFloat1, float paramFloat2)
  {
    super.a(paramFloat1, paramFloat2);
    for (int i = 0; i < this.a.size(); i++)
    {
      ao localao = (ao)this.a.get(i);
      localao.l.postTranslate(paramFloat1, paramFloat2);
      localao.c();
    }
  }

  protected void a(float paramFloat1, float paramFloat2, float paramFloat3)
  {
    super.a(paramFloat1, paramFloat2, paramFloat3);
    Iterator localIterator = this.a.iterator();
    while (localIterator.hasNext())
    {
      ao localao = (ao)localIterator.next();
      localao.l.set(getImageMatrix());
      localao.c();
    }
  }

  public void a(ao paramao)
  {
    this.a.add(paramao);
    invalidate();
  }

  public void b()
  {
    super.b();
    Iterator localIterator = this.a.iterator();
    while (localIterator.hasNext())
    {
      ao localao = (ao)localIterator.next();
      localao.l.set(getImageMatrix());
      localao.c();
    }
  }

  public void c()
  {
    super.c();
    Iterator localIterator = this.a.iterator();
    while (localIterator.hasNext())
    {
      ao localao = (ao)localIterator.next();
      localao.l.set(getImageMatrix());
      localao.c();
    }
  }

  protected void onDraw(Canvas paramCanvas)
  {
    super.onDraw(paramCanvas);
    for (int i = 0; i < this.a.size(); i++)
      ((ao)this.a.get(i)).a(paramCanvas);
  }

  protected void onLayout(boolean paramBoolean, int paramInt1, int paramInt2, int paramInt3, int paramInt4)
  {
    super.onLayout(paramBoolean, paramInt1, paramInt2, paramInt3, paramInt4);
    if (this.h.b() != null)
    {
      Iterator localIterator = this.a.iterator();
      while (localIterator.hasNext())
      {
        ao localao = (ao)localIterator.next();
        localao.l.set(getImageMatrix());
        localao.c();
        if (!localao.h)
          continue;
        c(localao);
      }
    }
  }

  public boolean onTouchEvent(MotionEvent paramMotionEvent)
  {
    int i = 0;
    ActivityCropImage localActivityCropImage = (ActivityCropImage)getContext();
    if (localActivityCropImage.b)
      return i;
    switch (paramMotionEvent.getAction())
    {
    default:
      label48: switch (paramMotionEvent.getAction())
      {
      default:
      case 1:
      case 2:
      }
    case 0:
    case 1:
    case 2:
    }
    while (true)
    {
      i = 1;
      break;
      if (localActivityCropImage.a)
      {
        a(paramMotionEvent);
        break label48;
      }
      for (int m = 0; m < this.a.size(); m++)
      {
        ao localao2 = (ao)this.a.get(m);
        int n = localao2.a(paramMotionEvent.getX(), paramMotionEvent.getY());
        if (n == 1)
          continue;
        this.e = n;
        this.b = localao2;
        this.c = paramMotionEvent.getX();
        this.d = paramMotionEvent.getY();
        ao localao3 = this.b;
        if (n == 32);
        for (m localm = m.b; ; localm = m.c)
        {
          localao3.a(localm);
          break;
        }
      }
      if (localActivityCropImage.a)
        for (int j = 0; ; j++)
        {
          if (j >= this.a.size())
            break label366;
          ao localao1 = (ao)this.a.get(j);
          if (!localao1.a())
            continue;
          localActivityCropImage.c = localao1;
          int k = 0;
          if (k < this.a.size())
          {
            if (k == j);
            while (true)
            {
              k++;
              break;
              ((ao)this.a.get(k)).b(true);
            }
          }
          c(localao1);
          ((ActivityCropImage)getContext()).a = false;
          i = 1;
          break;
        }
      if (this.b != null)
      {
        c(this.b);
        this.b.a(m.a);
      }
      label366: this.b = null;
      break label48;
      if (localActivityCropImage.a)
      {
        a(paramMotionEvent);
        break label48;
      }
      if (this.b == null)
        break label48;
      this.b.a(this.e, paramMotionEvent.getX() - this.c, paramMotionEvent.getY() - this.d);
      this.c = paramMotionEvent.getX();
      this.d = paramMotionEvent.getY();
      b(this.b);
      break label48;
      a(true, true);
      continue;
      if (d() != 1.0F)
        continue;
      a(true, true);
    }
  }
}

/* Location:           D:\android\hack\dex2jar-0.0.9.8\classes_dex2jar.jar
 * Qualified Name:     com.netease.image.video.CropImageView
 * JD-Core Version:    0.6.0
 */